var e = getApp();

Page({
    data: {
        tempFilePaths: "",
        uploadUrl: "upload.uploadPic",
        imageUs: []
    },
    onLoad: function(e) {},
    delIntu: function(e) {
        var a = this.data.imageUs, o = e.currentTarget.id;
        if ("0" != o || "1" != a.length) {
            var t = a.splice(o, 1);
            console.log(o), console.log(t), this.setData({
                imageUs: t
            });
        } else this.setData({
            imageUs: ""
        });
    },
    tapin: function() {
        var e = this;
        wx.chooseImage({
            count: 9,
            sizeType: [ "original", "compressed" ],
            sourceType: [ "album", "camera" ],
            success: function(a) {
                console.log(a.tempFilePaths), e.unload({
                    tempFilePaths: a.tempFilePaths
                }, "1");
            }
        });
    },
    unload: function(a, o) {
        console.log(o);
        var t = e.getNetAddresss(this.data.uploadUrl), n = this, s = a.i ? a.i : 0, i = a.success ? a.success : 0, l = a.fail ? a.fail : 0;
        wx.uploadFile({
            url: t,
            filePath: a.tempFilePaths[s],
            name: "file",
            formData: null,
            success: function(e) {
                var a = JSON.parse(e.data);
                console.log(a), console.log(a.data.img), n.setData({
                    imageUs: n.data.imageUs.concat(a.data.img_url)
                });
            },
            fail: function(e) {
                l++;
            },
            complete: function(e) {
                ++s == a.tempFilePaths.length ? (console.log("执行完毕"), console.log("成功：" + i + " 失败：" + l)) : (a.i = s, 
                a.success = i, a.fail = l, n.unload(a, o));
            }
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {}
});